#include<iostream>
#include<cstring>
#include<cstdlib>
#include<stdio.h>
#include<map>

using namespace std;

int main()
{
     string s;
     string first,second;
     map<string,string>  m;
     while( getline(cin,s) )
     {
         if( s.empty() )       
         {
             break;    
         } 
         int pos = s.find(" ");
         first = s.substr(0,pos);
         second = s.substr(pos+1,s.length()-pos-1);
         m[second] = first;
         //cout<<m[second]<<endl;
     }
   
     string ss;
     while(cin>>ss)
     {
         if( !m[ss].empty())             
         {
             cout<<m[ss]<<endl;    
         }
         else
         {
             cout<<"eh"<<endl;
         }
     }
     
     system("pause");
     return 0;
} 
